package cn.tedu.egmvc3.controller;

import cn.tedu.egmvc3.mappers.EmpMapper;
import cn.tedu.egmvc3.pojo.entyti.Emp;
import cn.tedu.egmvc3.pojo.vo.EmpVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/emp/")
public class AddressController {
    @Autowired
    private EmpMapper empMapper;
    @RequestMapping("insert")
    public String insertAddress(EmpVO empVO){
        Emp emp = new Emp();
        BeanUtils.copyProperties(empVO,emp);
        empMapper.insert(emp);
        return "添加成功";
    }
    @RequestMapping("select")
    public List<Emp> selectAddress(){
        return empMapper.select();
    }
   @RequestMapping("delete")
    public String deleteAddress(Integer id){
        empMapper.delete(id);
       return "删除成功";
    }
    @RequestMapping("update")
    public String updateAddress(Emp emp){
        empMapper.update(emp);
        return "修改成功";
    }
}
